<!DOCTYPE html>

<html lang="zh-hans">
<head>
    <title>发送信息 | 管理系统</title>
    <link rel="stylesheet" type="text/css" href="/static/admin/css/base.css">
    <link rel="stylesheet" type="text/css" href="/static/admin/css/forms.css">
    <script type="text/javascript" src="/admin/jsi18n/"></script>
    <script type="text/javascript" src="/static/admin/js/vendor/jquery/jquery.js"></script>
    <script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>
    <script type="text/javascript" src="/static/admin/js/core.js"></script>
    <script type="text/javascript" src="/static/admin/js/admin/RelatedObjectLookups.js"></script>
    <script type="text/javascript" src="/static/admin/js/actions.js"></script>
    <script type="text/javascript" src="/static/admin/js/urlify.js"></script>
    <script type="text/javascript" src="/static/admin/js/prepopulate.js"></script>
    <script type="text/javascript" src="/static/admin/js/vendor/xregexp/xregexp.js"></script>

    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <link href="https://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script>

    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/static/admin/css/responsive.css">
    <meta name="robots" content="NONE,NOARCHIVE">
</head>

<body class="popup  app-blog model-source change-form"
      data-admin-utc-offset="28800">
<!-- Container -->
<div id="container">
    <!-- Content -->
    <div id="content" class="colM">
        <h1>增加 信息</h1>
        <div id="content-main">
            <form id="source_form" method="post">
                <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
                <div>
                    <fieldset class="module aligned ">
                        <div class="form-row">
                            <div>
                                <label for="qr_platform">接码平台</label>
                                <ul id="qr_platform" class="form-control">
                                    {% for key, value in form.qr_platform.items %}
                                        <li>
                                            <label for="qr_platform_{{ forloop.counter }}">
                                                <input type="radio" name="qr_platform"
                                                       class="form-control" required=""
                                                       id="qr_platform_{{ forloop.counter }}"
                                                       {% if value == "1" %}checked{% endif %} value="{{ key }}">
                                                {{ key }}
                                            </label>
                                        </li>
                                    {% endfor %}
                                </ul>
                                <small class=""></small>
                            </div>
                        </div>

                        <div class="form-row">
                            <div>
                                <label for="qr_account">接码平台账号</label>
                                <input type="text" name="qr_account" style="width:60%;" id="qr_account"
                                       value="{{ form.qr_account }}">
                                <small class=""></small>
                            </div>
                        </div>

                        <div class="form-row">
                            <div>
                                <label for="qr_password">接码平台密码</label>
                                <input type="text" name="qr_password" style="width:60%;" id="qr_password"
                                       value="{{ form.qr_password }}">
                                <small class=""></small>
                            </div>
                        </div>

                        <div class="form-row">
                            <div>
                                <label for="project_id">项目编号</label>
                                <input type="text" name="project_id" style="width:60%;" id="project_id"
                                       value="{{ form.project_id }}">
                                <small class=""></small>
                            </div>
                        </div>

                        <div class="form-row">
                            <div>
                                <label for="assist_platform">辅助平台</label>
                                <ul id="assist_platform" class="form-control">
                                    {% for key, value in form.assist_platform.items %}
                                        <li>
                                            <label for="assist_platform_{{ forloop.counter }}">
                                                <input type="radio" name="assist_platform"
                                                       class="form-control" required=""
                                                       id="assist_platform_{{ forloop.counter }}"
                                                       {% if value == "1" %}checked{% endif %} value="{{ key }}">
                                                {{ key }}
                                            </label>
                                        </li>
                                    {% endfor %}
                                </ul>
                                <small class=""></small>
                            </div>
                        </div>

                        <div class="form-row">
                            <div>
                                <label for="assist_account">辅助平台账号</label>
                                <input type="text" name="assist_account" style="width:60%;" id="assist_account"
                                       value="{{ form.assist_account }}">
                                <small class=""></small>
                            </div>
                        </div>

                        <div class="form-row">
                            <div>
                                <label for="assist_password">辅助平台密码</label>
                                <input type="text" name="assist_password" style="width:60%;" id="assist_password"
                                       value="{{ form.assist_password }}">
                                <small class=""></small>
                            </div>
                        </div>

                        <div class="form-row">
                            <div>
                                <label for="user_key">用户 KEY</label>
                                <input type="text" name="user_key" style="width:60%;" id="user_key"
                                       value="{{ form.user_key }}">
                                <small class=""></small>
                            </div>
                        </div>
                        <div class="form-row">
                            <div>
                                <label for="user_key">平台 CK</label>
                                <input type="text" name="platform_ck" style="width:60%;" id="platform_ck"
                                       value="{{ form.platform_ck }}">
                                <small class=""></small>
                            </div>
                        </div>

                        <div class="form-row">
                            <div>
                                <label for="ip_sets">IP 设置</label>
                                <ul id="ip_sets" class="form-control">
                                    {% for key, value in form.ip_sets.items %}
                                        <li>
                                            <label for="ip_sets_{{ forloop.counter }}">
                                                <input type="radio" name="ip_sets"
                                                       class="form-control" required=""
                                                       id="ip_sets_{{ forloop.counter }}"
                                                       {% if value == "1" %}checked{% endif %} value="{{ key }}">
                                                {{ key }}
                                            </label>
                                        </li>
                                    {% endfor %}
                                </ul>
                                <small class=""></small>
                            </div>
                        </div>

                        <div class="form-row">
                            <div>
                                <label for="ip_times">IP 次数</label>
                                <input type="text" name="ip_times" style="width:60%;" id="ip_times"
                                       value="{{ form.ip_times }}">
                                <small class=""></small>
                            </div>
                        </div>
                    </fieldset>

                    <div class="submit-row">
                        <a href="javascript:window.opener=null;window.open('','_self');window.close();"
                           class="closelink" id="close_pc" style="display:none">关闭</a>

                        {#                        <a href="#" onClick="javascript:history.back(-1);" class="closelink" id="close_phone"#}
                        {#                           style="display: none">关闭</a>#}

                        <a href="{{ pre_page_url }}" class="closelink" id="close_phone"
                           style="display: none">关闭</a>

                        {#                        <input type="submit" value="发送" class="default" name="_save" id="submit" onclick="submit()">#}
                        <input type="button" class="default" onclick="send_mes()" value="发送">
                    </div>

                    <script type="text/javascript"
                            id="django-admin-form-add-constants"
                            src="/static/admin/js/change_form.js"
                            data-model-name="source">
                    </script>
                    <script type="text/javascript"
                            id="django-admin-prepopulated-fields-constants"
                            src="/static/admin/js/prepopulate_init.js"
                            data-prepopulated-fields="[]">
                    </script>

                </div>
            </form>
            <script>
                // 关闭适应 手机端 和 PC 端
                try {
                    if (/Android|iOS|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)) {
                        $("#close_phone").attr("style", "display:block;");
                    } else {
                        $("#close_phone").attr("style", "display:inline-block;");
                    }
                } catch (e) {
                    console.log("设置失败")
                }

                // 发送
                function send_mes() {
                    {#$("#source_form").submit(function () {#}
                    $.ajax({
                        url: '/blog/json_parse',
                        type: "POST",
                        dataType: "json",
                        async: false,
                        data: {
                            "csrfmiddlewaretoken": "{{ csrf_token }}",
                            "qr_platform": $('input[name="qr_platform"]:checked').val(),
                            "qr_account": $('input[name="qr_account"]').val(),
                            "qr_password": $('input[name="qr_password"]').val(),
                            "project_id": $('input[name="project_id"]').val(),
                            "assist_platform": $('input[name="assist_platform"]:checked').val(),
                            "assist_account": $('input[name="assist_account"]').val(),
                            "assist_password": $('input[name="assist_password"]').val(),
                            "user_key": $('input[name="user_key"]').val(),
                            "platform_ck": $('input[name="platform_ck"]').val(),
                            "ip_sets": $('input[name="ip_sets"]:checked').val(),
                            "ip_times": $('input[name="ip_times"]').val(),
                        },
                        success: function (responese) {
                            {#console.log(responese);#}
                            if (responese.status < 400) {
                                toastr.info(responese.msg);
                                setTimeout(function () {
                                    if (/Android|iOS|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)) {
                                        window.location.href = "{{ pre_page_url }}";
                                    } else {
                                        window.location.href = "{{ pre_page_url }}";
                                        // window.close();
                                    }
                                }, 2500);
                            } else {
                                toastr.warning(responese.msg);
                            }
                        },
                        error: function () {
                            toastr.warning("请填写内容");
                        }
                    })
                }
            </script>

        </div>
        <br class="clear">
    </div>
    <!-- END Content -->

    <div id="footer"></div>
</div>
<!-- END Container -->

</body>
</html>
